package edu.washington.ling.syntric.struct.rule;

public class UniRule implements Comparable<UniRule> {
	private UniDSPattern dsPattern;
	private UniPSPattern psPattern;
	public UniRule(UniDSPattern dsPatt, UniPSPattern psPatt) {
		dsPattern = dsPatt;
		psPattern = psPatt;
	}
	public UniDSPattern getDSPattern() {
		return dsPattern;
	}
	public UniPSPattern getPSPattern() {
		return psPattern;
	}
	public boolean equals(Object other){
		if (this == other){
			return true;
		}
		if (!(other instanceof UniRule)) {
			return false;
		}
		UniRule otherRule = (UniRule) other;
		return (psPattern.equals(otherRule.psPattern) && dsPattern.equals(otherRule.dsPattern));
	}
	public int hashCode() {
		return psPattern.hashCode() + 31*dsPattern.hashCode();
	}
	@Override
	public int compareTo(UniRule otherRule) {
		int dsPattCmp = dsPattern.compareTo(otherRule.dsPattern);
		return (dsPattCmp != 0 ? dsPattCmp :
				psPattern.compareTo(otherRule.psPattern));
	}
}
